#ifndef SINGLEAPPLICATION_H
#define SINGLEAPPLICATION_H

#include <QCoreApplication>
#include <QApplication>
#include <QSharedMemory>
#include <QLocalServer>

class QSingleApplication : public QApplication
{
    Q_OBJECT
public:
    QSingleApplication(int &argc, char **argv, const QString uniqueKey);
    virtual ~QSingleApplication();

    bool isRunning();
    bool sendMessage(const QString &message);
    void closeLocalServer();

public slots:
    void receiveMessage();

signals:
    void messageAvailable(const QString &event);

private:
    bool running;
    QString uniqueKey;
    QSharedMemory sharedMemory;
    QLocalServer *localServer;
    static const int timeout = 3000;
};

#endif // SINGLEAPPLICATION_H
